home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / utils / file / managers / mc-3.2 / mc-3 / mc-3.2.1 / vfs / vfs.h < prev   
Encoding:
C/C++ Source or Header  |  1996-05-17  |  7.1 KB  |  254 lines

  1. #ifndef __VFS_H
  2. #define __VFS_H
  3.  
  4. #ifdef USE_VFS
  5.  
  6. #ifdef HAVE_MMAP
  7. #include <sys/mman.h>
  8. #endif
  9.  
  10. #include <sys/time.h>
  11.  
  12.     /* Our virtual file system layer */
  13.     
  14.     typedef void * vfsid;
  15.  
  16.     struct vfs_stamping;
  17.     
  18.     typedef struct {
  19.     void  *(*open)(char *fname, int flags, int mode);
  20.     int   (*close)(void *vfs_info);
  21.     int   (*read)(void *vfs_info, char *buffer, int count);
  22.     int   (*write)(void *vfs_info, char *buf, int count);
  23.  
  24.     void  *(*opendir)(char *dirname);
  25.     void  *(*readdir)(void *vfs_info);
  26.     int   (*closedir)(void *vfs_info);
  27.  
  28.     int  (*stat)(char *path, struct stat *buf);
  29.     int  (*lstat)(char *path, struct stat *buf);
  30.     int  (*fstat)(void *vfs_info, struct stat *buf);
  31.  
  32.     int  (*chmod)(char *path, int mode);
  33.     int  (*chown)(char *path, int owner, int group);
  34.  
  35.     int  (*readlink)(char *path, char *buf, int size);
  36.     int  (*symlink)(char *n1, char *n2);
  37.     int  (*link)(char *p1, char *p2);
  38.     int  (*unlink)(char *path);
  39.     int  (*rename)(char *p1, char *p2);
  40.     int  (*chdir)(char *path);
  41.     int  (*ferrno)(void);
  42.     int  (*lseek)(void *vfs_info, off_t offset, int whence);
  43.     int  (*mknod)(char *path, int mode, int dev);
  44.     
  45.     vfsid (*getid)(char *path, struct vfs_stamping **parent);
  46.     int  (*nothingisopen)(vfsid id);
  47.     void (*free)(vfsid id);
  48.     
  49.     char *(*getlocalcopy)(char *filename);
  50.     void (*ungetlocalcopy)(char *filename, char *local, int has_changed);
  51.  
  52.     int  (*mkdir)(char *path, mode_t mode);
  53.     int  (*rmdir)(char *path);
  54.     
  55.     int  (*ctl)(void *vfs_info, int ctlop, int arg);
  56.     int  (*setctl)(char *path, int ctlop, char *arg);
  57. #ifdef HAVE_MMAP
  58.     caddr_t (*mmap)(caddr_t addr, size_t len, int prot, int flags, void *vfs_info, off_t offset);
  59.     int (*munmap)(caddr_t addr, size_t len, void *vfs_info);
  60. #endif    
  61.     } vfs;
  62.  
  63.     /* Other file systems */
  64.     extern vfs local_vfs_ops;
  65.     extern vfs tarfs_vfs_ops;
  66.  
  67.     extern vfs ftpfs_vfs_ops;
  68.     extern vfs mcfs_vfs_ops;
  69.     
  70.     extern vfs extfs_vfs_ops;
  71.  
  72.     extern vfs undelfs_vfs_ops;
  73.  
  74.     struct vfs_stamping {
  75.         vfs *v;
  76.         vfsid id;
  77.         struct vfs_stamping *parent; /* At the moment applies to tarfs only */
  78.         struct vfs_stamping *next;
  79.         struct timeval time;
  80.     };
  81.  
  82.     void vfs_init (void);
  83.     void vfs_shut (void);
  84.  
  85.     extern int vfs_type_absolute;
  86.     vfs *vfs_type (char *path);
  87.     char *vfs_path (char *path);
  88.     char *vfs_canon (char *path);
  89.     char *mc_get_current_wd (char *buffer, int bufsize);
  90.     int vfs_current_is_local (void);
  91.     int vfs_current_is_extfs (void);
  92.     int vfs_file_is_local (char *name);
  93.     char *vfs_get_current_dir (void);
  94.     
  95.     void vfs_stamp (vfs *, vfsid);
  96.     void vfs_rmstamp (vfs *, vfsid, int);
  97.     void vfs_addstamp (vfs *, vfsid, struct vfs_stamping *);
  98.     void vfs_add_noncurrent_stamps (vfs *, vfsid, struct vfs_stamping *);
  99.     void vfs_add_current_stamps (void);
  100.     void vfs_free_resources(char *path);
  101.     void vfs_timeout_handler ();
  102.     int vfs_timeouts ();
  103.  
  104.     void vfs_fill_names (void (*)(char *));
  105.  
  106.     /* Required for the vfs_canon routine */
  107.     char *tarfs_analysis (char *inname, char **archive, int is_dir);
  108.  
  109.     void ftpfs_init(void);
  110.     void ftpfs_done(void);
  111. #ifdef USE_NETCODE
  112.     void ftpfs_hint_reread(int reread);
  113.     void ftpfs_flushdir(void);
  114. #else
  115. #   define ftpfs_flushdir()
  116. #   define ftpfs_hint_reread(x) 
  117. #endif
  118.     /* They fill the file system names */
  119.     void mcfs_fill_names (void (*)(char *));
  120.     void ftpfs_fill_names (void (*)(char *));
  121.     void tarfs_fill_names (void (*)(char *));
  122.     
  123.     char *ftpfs_gethome (char *);
  124.     char *mcfs_gethome (char *);
  125.     
  126.     char *ftpfs_getupdir (char *);
  127.     char *mcfs_getupdir (char *);
  128.  
  129.     /* Only the routines outside of the VFS module need the emulation macros */
  130.  
  131.     int mc_open (char *file, int flags, ...);
  132.     int mc_close (int handle);
  133.     int mc_read (int handle, char *buffer, int count);
  134.     int mc_write (int hanlde, char *buffer, int count);
  135.     off_t mc_lseek (int fd, off_t offset, int whence);
  136.     int mc_chdir (char *);
  137.  
  138.     DIR *mc_opendir (char *dirname);
  139.     struct dirent *mc_readdir(DIR *dirp);
  140.     int mc_closedir (DIR *dir);
  141.  
  142.     int mc_stat (char *path, struct stat *buf);
  143.     int mc_lstat (char *path, struct stat *buf);
  144.     int mc_fstat (int fd, struct stat *buf);
  145.  
  146.     int mc_chmod (char *path, int mode);
  147.     int mc_chown (char *path, int owner, int group);
  148.     int mc_readlink(char *path, char *buf, int bufsiz);
  149.     int mc_unlink (char *path);
  150.     int mc_symlink (char *name1, char *name2);
  151.         int mc_link (char *name1, char *name2);
  152.         int mc_mknod (char *, int, int);
  153.     int mc_rename (char *original, char *target);
  154.     int mc_write (int fd, char *buf, int nbyte);
  155.         int mc_rmdir (char *path);
  156.         int mc_mkdir (char *path, mode_t mode);
  157.         char *mc_getlocalcopy (char *filename);
  158.         void mc_ungetlocalcopy (char *filename, char *local, int has_changed);
  159.         char *mc_def_getlocalcopy (char *filename);
  160.         void mc_def_ungetlocalcopy (char *filename, char *local, int has_changed);
  161.         int mc_ctl (int fd, int ctlop, int arg);
  162.         int mc_setctl (char *path, int ctlop, char *arg);
  163. #ifdef HAVE_MMAP
  164.         caddr_t mc_mmap (caddr_t, size_t, int, int, int, off_t);
  165.         int mc_unmap (caddr_t, size_t);
  166.             int mc_munmap (caddr_t addr, size_t len);
  167. #endif /* HAVE_MMAP */
  168.  
  169. #else
  170.  
  171. #   define vfs_fill_names(x)
  172. #   define vfs_add_current_stamps()
  173. #   define vfs_current_is_local() 1
  174. #   define vfs_file_is_local(x) 1
  175. #   define vfs_path(x) x
  176. #   define mc_open open
  177. #   define mc_close close
  178. #   define mc_read read
  179. #   define mc_write write
  180. #   define mc_lseek lseek
  181. #   define mc_opendir opendir
  182. #   define mc_readdir readdir
  183. #   define mc_closedir closedir
  184.  
  185. #   define mc_get_current_wd(x,size) get_current_wd (x, size)
  186. #   define mc_fstat fstat
  187. #   define mc_lstat lstat
  188.  
  189. #   define mc_chmod chmod
  190. #   define mc_chown chown
  191. #   define mc_readlink readlink
  192. #   define mc_unlink unlink
  193. #   define mc_symlink symlink
  194. #   define mc_rename rename
  195. #   define mc_chdir chdir
  196.     
  197. #   define mc_mmap mmap
  198. #   define mc_munmap munmap
  199.  
  200. #   define mc_ctl 0
  201. #   define mc_setctl(a,b,c)
  202.  
  203. #   define mc_stat stat
  204. #   define mc_mknod mknod
  205. #   define mc_link link
  206. #   define mc_mkdir mkdir
  207. #   define mc_rmdir rmdir
  208. #   define is_special_prefix(x) 0
  209. #   define vfs_type(x) (vfs *)(NULL)
  210. #   define vfs_setup_wd()
  211. #   define vfs_init()
  212. #   define vfs_shut()
  213. #   define vfs_canon(p) strdup (canonicalize_pathname(p))
  214. #   define vfs_free_resources()
  215. #   define vfs_timeout_handler()
  216. #   define vfs_timeouts() 0
  217.  
  218.     typedef int vfs;
  219.     
  220. #   define mc_getlocalcopy(x) NULL
  221. #   define mc_ungetlocalcopy(x,y,z)
  222.  
  223. #   define ftpfs_hint_reread(x) 
  224. #   define ftpfs_flushdir()
  225. #endif /* USE_VFS */
  226.  
  227. #define mc_errno errno
  228.  
  229. #ifdef WANT_PARSE_LS_LGA
  230. int parse_ls_lga (char *p, struct stat *s, char **filename, char **linkname);
  231. #endif
  232.  
  233. #define MCCTL_SETREMOTECOPY    0
  234. #define MCCTL_ISREMOTECOPY    1
  235. #define MCCTL_REMOTECOPYCHUNK    2
  236. #define MCCTL_FINISHREMOTE    3
  237. #define MCCTL_FLUSHDIR          4
  238.  
  239. /* Return codes from the ${fs}_ctl routine */
  240.  
  241. #define MCERR_TARGETOPEN    -1
  242.     /* Can't open target file */
  243. #define MCERR_READ        -2
  244.     /* Read error on source file */
  245. #define MCERR_WRITE        -3
  246.     /* Write error on target file */
  247. #define MCERR_FINISH        -4
  248.     /* Finished transfer */
  249. #define MCERR_DATA_ON_STDIN     -5
  250.     /* Data waiting on stdin to be processed */
  251.  
  252. #endif /* __VFS_H */
  253.  
  254.